package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.Details;
import com.ruoyi.wechat.service.IDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营地预约详情Controller
 * 
 * @author ruoyi
 * @date 2024-07-30
 */
@RestController
@RequestMapping("/camp/details")
public class DetailsController extends BaseController
{
    @Autowired
    private IDetailsService detailsService;

    /**
     * 查询营地预约详情列表
     */
    @PreAuthorize("@ss.hasPermi('camp:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(Details details)
    {
        startPage();
        List<Details> list = detailsService.selectDetailsList(details);
        return getDataTable(list);
    }

    /**
     * 导出营地预约详情列表
     */
    @PreAuthorize("@ss.hasPermi('camp:details:export')")
    @Log(title = "营地预约详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Details details)
    {
        List<Details> list = detailsService.selectDetailsList(details);
        ExcelUtil<Details> util = new ExcelUtil<Details>(Details.class);
        util.exportExcel(response, list, "营地预约详情数据");
    }

    /**
     * 获取营地预约详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:details:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") String detailId)
    {
        return success(detailsService.selectDetailsByDetailId(detailId));
    }

    /**
     * 新增营地预约详情
     */
    @PreAuthorize("@ss.hasPermi('camp:details:add')")
    @Log(title = "营地预约详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Details details)
    {
        return toAjax(detailsService.insertDetails(details));
    }

    /**
     * 修改营地预约详情
     */
    @PreAuthorize("@ss.hasPermi('camp:details:edit')")
    @Log(title = "营地预约详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Details details)
    {
        return toAjax(detailsService.updateDetails(details));
    }

    /**
     * 删除营地预约详情
     */
    @PreAuthorize("@ss.hasPermi('camp:details:remove')")
    @Log(title = "营地预约详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable String[] detailIds)
    {
        return toAjax(detailsService.deleteDetailsByDetailIds(detailIds));
    }
}
